require(["common", "jQuery", "coAjax"], function(jSouper, $, coAjax) {
	//进入编辑状态
	App.set("$Event.admin.to_edit", function(e) {
		App.set("$Cache.admininfo.is_edit", true);
	});
	//完成编辑，提交表单
	App.set("$Event.admin.post_edit", function(e) {
		var info = App.get("bus_loginer.info");
		coAjax.put(appConfig.bus.set_info_url, info, function(result) {
			// console.log(result);
			alert("success", "修改完成");
			App.set("bus_loginer", result.result)
			App.set("$Cache.admininfo.is_edit", false);
		}, function(errorCode, xhr, errorMsg) {
			switch (errorCode) {
				case "00025":
					alert("error", "登录超时");
					href.toLogin();
					break;
				case "00041":
					alert("error", "请检查您的身份证格式");
					break;
				case "00043":
					alert("error", "请检查您的邮箱格式");
					break;
				case "00044":
					alert("error", "请检查您的手机号码");
					break;
				default:
					alert("error", errorMsg);
			}
		});
	});
	//取消编辑
	App.set("$Event.admin.cancel_edit", function(e) {
		coAjax.get(appConfig.bus.loginer, function(result) {
			App.set("bus_loginer", result.result);
		});
		App.set("$Cache.admininfo.is_edit", false);
	});

	App.set("$Event.admin.storeinfo.get_address", function(e) {
		var address_info = this.data;
		address_info = {
			province: address_info.province && address_info.province.region_name,
			town: address_info.town && address_info.town.region_name,
			county: address_info.county && address_info.county.region_name,
			detail: address_info.detail
		};
		App.set("bus_loginer.info.address_info",address_info);
	});
})